home *** CD-ROM | disk | FTP | other *** search
/ Precision Software Appli…tions Silver Collection 1 / Precision Software Applications Silver Collection Volume One (PSM) (1993).iso / windows / games / blast.arj / BLAST.C < prev    next >
C/C++ Source or Header  |  1988-08-15  |  3KB  |  117 lines

  1. /*** Include files needed for definitions, declarations, etc.          ***/
  2. #include <windows.h>  /* Required for all Windows programs        */
  3. #include <stdlib.h>
  4.  
  5. /*** Forward declare functions                          ***/
  6. long FAR PASCAL WndProc (HWND, unsigned, WORD, LONG);
  7.  
  8. HANDLE      hInst;
  9.  
  10.  
  11. int PASCAL WinMain (hInstance, hPrevInstance, lpszCmdLine, nCmdShow)
  12.     HANDLE    hInstance, hPrevInstance;
  13.     LPSTR    lpszCmdLine;
  14.     int     nCmdShow;
  15.     {
  16.     HWND    hWnd;
  17.     MSG     msg;
  18.     WNDCLASS    wndclass;
  19.  
  20.     if (!hPrevInstance)
  21.     {
  22.     wndclass.style        = CS_HREDRAW;
  23.     wndclass.lpfnWndProc    = WndProc;
  24.     wndclass.cbClsExtra    = 0;
  25.     wndclass.cbWndExtra    = 0;
  26.     wndclass.hInstance    = hInstance;
  27.     wndclass.hIcon        = NULL;
  28.     wndclass.hCursor    = LoadCursor (hInstance, IDC_ARROW);
  29.     wndclass.hbrBackground    = GetStockObject (WHITE_BRUSH);
  30.     wndclass.lpszMenuName    = NULL;
  31.     wndclass.lpszClassName    = "Blast";
  32.  
  33.     if (!RegisterClass (&wndclass) )
  34.     return FALSE;
  35.     }
  36.     else
  37.     return FALSE;
  38.  
  39.     hInst=hInstance;
  40.     hWnd = CreateWindow ("Blast", "Blast", WS_OVERLAPPEDWINDOW, 0, 0,
  41.             0,0, NULL, NULL, hInstance, NULL);
  42.  
  43.  
  44.     if(!SetTimer(hWnd, 1, 50, NULL))
  45.     {
  46.     MessageBox(hWnd, "Too many clocks or timers!", "Error",
  47.            MB_ICONEXCLAMATION | MB_OK);
  48.     return FALSE;
  49.     }
  50.  
  51.     while (GetMessage(&msg, NULL, 0,0 ))
  52.     {
  53.     TranslateMessage(&msg);
  54.     DispatchMessage(&msg);
  55.     }
  56.     return msg.wParam;
  57.     }
  58.  
  59. long FAR PASCAL WndProc (hWnd, iMessage, wParam, lParam)
  60.     HWND      hWnd;
  61.     unsigned      iMessage;
  62.     WORD      wParam;
  63.     LONG      lParam;
  64.     {
  65.     static HANDLE hBitmap;
  66.     BITMAP      bm;
  67.     HDC       hDC,hMemDC;
  68.     short      nRand, nIndex;
  69.     long      xStart, yStart;
  70.     char      szJunk[40];
  71.  
  72.  
  73.  
  74.     switch (iMessage)
  75.     {
  76.     case WM_TIMER:
  77.         if(rand() < 1500)
  78.         {
  79.         OpenSound();
  80.         SetVoiceQueueSize(1, 1000);
  81.         SetVoiceAccent(1, 220, 20, S_NORMAL, 0);
  82.         for (nIndex=84; nIndex > 0; nIndex -=1 )
  83.             SetVoiceNote(1, nIndex, 250, 0);
  84.         StartSound();
  85.  
  86.         hBitmap=LoadBitmap(hInst, "Blast");
  87.         GetObject(hBitmap, sizeof(BITMAP), (LPSTR) &bm);
  88.  
  89.         hDC=CreateDC("DISPLAY", NULL, NULL, NULL);
  90.         hMemDC=CreateCompatibleDC(hDC);
  91.         SelectObject(hMemDC, hBitmap);
  92.  
  93.         xStart=rand() % GetSystemMetrics(SM_CXSCREEN);
  94.         yStart=rand() % GetSystemMetrics(SM_CYSCREEN);
  95.         BitBlt(hDC, (short)xStart, (short)yStart, bm.bmWidth, bm.bmHeight,
  96.                hMemDC, 0,0, SRCAND);
  97.  
  98.         DeleteDC(hDC);
  99.         DeleteDC(hMemDC);
  100.         }
  101.         break;
  102.  
  103.     case WM_CREATE:
  104.         srand((unsigned)GetTickCount());
  105.         break;
  106.  
  107.     case WM_DESTROY:
  108.         DeleteObject(hBitmap);
  109.         PostQuitMessage(0);
  110.         break;
  111.  
  112.     default:
  113.         return (DefWindowProc(hWnd, iMessage, wParam, lParam));
  114.     }
  115.     return 0L;
  116. }
  117.